function includeExJS(jsFilepath){
    var exJS = document.createElement('script');
    exJS.src = jsFilepath;
    document.head.appendChild(exJS);
}
includeExJS("/base.js");

export function getUrl() {
	return window.location.host.search('dps')!= -1 ? '/dps-jeecg-boot' : '/jeecg-boot'
	// return URL_API
}
export function getWebsiteUrl() {
	return window.location.host.search('dps')!= -1 ? '/dps-jeecg-boot' : '/jeecg-boot'
	// return URL_API
}
/**
 * 拼接完整请求路径
 */
export function spliceUrl(path) {
	return getUrl() + path
}

export function spliceWebsiteUrl(path) {
	return getWebsiteUrl() + path
}
/*------------------------------------------------*/

export function getUrlWechat() {
	return window.location.host.search('dps')!= -1 ? '/dps-jeecg-boot' : '/jeecg-boot'
	// return URL_API
}
export function getWebsiteUrlWechat() {
	return window.location.host.search('dps')!= -1 ? '/dps-jeecg-boot' : '/jeecg-boot'
	// return URL_API
}
export function spliceUrlWechat(path) {
	return getUrlWechat() + path
}
export function spliceWebsiteUrlWechat(path) {
	return getWebsiteUrlWechat() + path
}

/*------------------------------------------------*/

export function getNow(s) {
	return s < 10 ? '0' + s : s
}

export function getAction(url, parameter) {
	if (!parameter) {
		parameter = {}
	}
	if (localStorage.getItem('staffid')) {
		parameter.staffId = localStorage.getItem('staffid')
	}
	if (localStorage.getItem('staffname')) {
		parameter.staffName = localStorage.getItem('staffname')
	}
	return axios({
		url: url,
		method: 'get',
		params: parameter,
	})
}

export function postAction(url, parameter) {
	if (!parameter) {
		parameter = {}
	}
	if (localStorage.getItem('staffid')) {
		parameter.staffId = localStorage.getItem('staffid')
	}
	if (localStorage.getItem('staffname')) {
		parameter.staffName = localStorage.getItem('staffname')
	}
	return axios({
		url: url,
		method: 'post',
		data: parameter,
	})
}
export function deleteAction(url, parameter) {
	if (!parameter) {
		parameter = {}
	}
	if (localStorage.getItem('staffid')) {
		parameter.staffId = localStorage.getItem('staffid')
	}
	if (localStorage.getItem('staffname')) {
		parameter.staffName = localStorage.getItem('staffname')
	}
	return axios({
		url: url,
		method: 'delete',
		params: parameter,
	})
}
export function sum(arr) {
	var s = 0
	for (var i = arr.length - 1; i >= 0; i--) {
		s += arr[i]
	}
	return s
}

export function avg(dataIntArr) {
	var avg = 0
	for (var i = 0; i < dataIntArr.length; i++) {
		avg += parseFloat(dataIntArr[i])
	}
	if (dataIntArr.length == 0) {
		return 0
	} else {
		return (avg / dataIntArr.length).toFixed(1)
	}
}

export function remove(arr) {
	var arr1 = []
	for (var i = 0; i < arr.length; i++) {
		if (arr[i] != '0') {
			arr1.push(arr[i])
		}
	}
	arr = arr1
	return arr
}
